<html>
<head><meta charset="utf-8"><title>cargo install ignores paths overrides · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html">cargo install ignores paths overrides</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="237644113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/237644113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#237644113">(May 06 2021 at 11:44)</a>:</h4>
<p>Hi all, I hope this is the right place to ask.</p>
<p>Does anyone know if <code>cargo install</code> respects the <code>paths</code> overrides in <code>.cargo/config.toml</code>? As far as I can tell, it does not, even though <code>cargo build</code> does the right thing. Is this intended behaviour / how can we work around it (other than doing the install ourselves manually)?</p>
<p>For the curious: our use case is that we're porting rust to a new OS so we have to patch <code>libc</code> and such (upstreaming isn't viable for us atm as we like to break things). As far as I can tell <code>paths</code> overrides is the best way to do this transparently (or maybe not?)</p>



<a name="237680050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/237680050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#237680050">(May 06 2021 at 15:37)</a>:</h4>
<p>It depends on how you are running <code>cargo install</code>.  If it is <code>cargo install --path FOO</code>, then it loads the config from CARGO_HOME and FOO are any ancestor.</p>
<p>In general, <code>paths</code> overrides are kinda old and can be finicky.  <code>[patch]</code> tables are the recommended way to override a dependency.</p>
<p>But if you are doing this in <code>rust-lang/rust</code>, it does not use <code>cargo install</code>, so I'm a bit confused on that part.  Regardless, if you are porting rustc, I would recommend using <code>[patch]</code>.</p>



<a name="237718999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/237718999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#237718999">(May 06 2021 at 19:54)</a>:</h4>
<p><span class="user-mention" data-user-id="120518">@Eric Huss</span>  we use <code>paths</code> as a sort of global patch, so that any crate which tries to depend on libc will grab it from our local copy rather than <a href="http://crates.io">crates.io</a> — if i understand it correctly, [patch] is per-crate (is this right?)</p>
<p>for rustc itself we just modify the Cargo.toml to depend on our libc directly (rather than relying on any cargo config.toml)</p>
<p>yes, we are using <code>cargo install --path foo</code> my original point was that it seems to have picked up the cargo config.toml (since it is using the right target and such) but it isn’t applying the <code>paths</code> correctly — i will triple check that though</p>



<a name="237719340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/237719340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#237719340">(May 06 2021 at 19:58)</a>:</h4>
<p>You may be interested in the unstable <a href="https://doc.rust-lang.org/cargo/reference/unstable.html#patch-in-config">https://doc.rust-lang.org/cargo/reference/unstable.html#patch-in-config</a></p>



<a name="237719633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/237719633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#237719633">(May 06 2021 at 20:00)</a>:</h4>
<p>oh nice, that looks perfect</p>



<a name="237974562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/237974562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#237974562">(May 08 2021 at 18:12)</a>:</h4>
<p>Now that we've switched over to <code>patch-in-config</code>, I think the reason why <code>paths</code> wasn't working with install there becomes apparent: we get a 'patched crate is not used in dependency graph' warning</p>
<p>Here is the scenario: we build <code>ripgrep</code> which has <code>libc</code> version 0.2.71 in its lockfile. When we go to build, it sees that our patched  libc (which has version <code>0.2.93</code>) can't be used, so it falls back to <a href="http://crates.io">crates.io</a> and complains  (same behaviour with <code>install --locked</code>).</p>
<p>If we instead <code>cargo install</code> (without <code>--locked</code>), then it tries to grab the latest version of <code>libc</code> which is now <code>0.2.94</code>, and since this is incompatible with our patch (0.2.93) it gives the same warning and then errors</p>
<p>As far as I can tell the only real workaround is to do <code>cargo update -p libc --precise 0.2.93</code> first, then <code>install --locked</code>, which is a bit annoying as now we have to hardcode 0.2.93 in some places that is a bit inconvenient</p>
<p>we really just need some way for our patch to shadow all previous compatible versions of the crate (then when it goes to grab <code>0.2.71</code> it will use our version), but afaict this isn't possible with <code>[patch]</code> -- any thoughts?</p>



<a name="237986035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/237986035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#237986035">(May 08 2021 at 21:31)</a>:</h4>
<blockquote>
<p>we really just need some way for our patch to shadow all previous compatible versions of the crate</p>
</blockquote>
<p>We where just starting to talk about something like that, but it is still at the talking stage. </p>
<blockquote>
<p>When we go to build, it sees that our patched libc (which has version 0.2.93) can't be used</p>
</blockquote>
<p>In what way cant it be used? If is likely that if it did not fall back it would just fail at that point.</p>



<a name="238026428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238026428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238026428">(May 09 2021 at 10:36)</a>:</h4>
<p><span class="user-mention" data-user-id="120179">@Eh2406</span> well 0.2.71 is in the lockfile and our patch has version 0.2.93 so it won’t use it right? at least that’s what seems to be happening</p>



<a name="238026571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238026571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238026571">(May 09 2021 at 10:39)</a>:</h4>
<p>is there a place where this discussion is happening? some github issue perhaps?</p>



<a name="238027443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238027443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238027443">(May 09 2021 at 10:53)</a>:</h4>
<p>(it’s also a bit strange because <code>paths</code> doesn’t seem to have a problem with that lockfile version mismatch, but <code>[patch]</code> does)</p>



<a name="238152566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238152566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238152566">(May 10 2021 at 14:37)</a>:</h4>
<p>(somewhat related issue that i've run into now: <a href="https://github.com/rust-lang/cargo/issues/9470">https://github.com/rust-lang/cargo/issues/9470</a>)</p>



<a name="238156854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238156854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238156854">(May 10 2021 at 15:01)</a>:</h4>
<p>It looks like maybe you are using <code>cargo install</code> of a crate from <a href="http://crates.io">crates.io</a>?  In that case, you won't be able to patch it.  You'll need to download the package and modify the lock file to patch the specific version of libc that you are using.</p>
<p><span class="user-mention silent" data-user-id="228354">Matt Taylor</span> <a href="#narrow/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides/near/238026571">said</a>:</p>
<blockquote>
<p>is there a place where this discussion is happening? some github issue perhaps?</p>
</blockquote>
<p>It was just an question posed during a team meeting, there aren't any github issues for it that I am aware of.</p>



<a name="238159767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238159767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238159767">(May 10 2021 at 15:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides/near/238156854">said</a>:</p>
<blockquote>
<p>It looks like maybe you are using <code>cargo install</code> of a crate from <a href="http://crates.io">crates.io</a>?  In that case, you won't be able to patch it.  You'll need to download the package and modify the lock file to patch the specific version of libc that you are using.</p>
</blockquote>
<p>Yeah, that is what we are currently doing, but it is quite clunky:</p>
<p><span class="user-mention silent" data-user-id="228354">Matt Taylor</span> <a href="#narrow/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides/near/237974562">said</a>:</p>
<blockquote>
<p>As far as I can tell the only real workaround is to do <code>cargo update -p libc --precise 0.2.93</code> first, then <code>install --locked</code>, which is a bit annoying as now we have to hardcode 0.2.93 in some places that is a bit inconvenient</p>
<p>we really just need some way for our patch to shadow all previous compatible versions of the crate (then when it goes to grab <code>0.2.71</code> it will use our version), but afaict this isn't possible with <code>[patch]</code> -- any thoughts?</p>
</blockquote>



<a name="238160102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238160102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238160102">(May 10 2021 at 15:19)</a>:</h4>
<p>TL;DR It would be nice if we could patch out all versions of the crate which are compatible with our patched version</p>



<a name="238160419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/cargo%20install%20ignores%20paths%20overrides/near/238160419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Taylor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/cargo.20install.20ignores.20paths.20overrides.html#238160419">(May 10 2021 at 15:21)</a>:</h4>
<p>(not to mention the related issue which is causing trouble)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>